﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YmtAuth.Common.Extend
{
   public static class Dictionary_Extend
    {
       public static TValue TryGet<TKey, TValue>(this IDictionary<TKey, TValue> val, TKey key,
           TValue defValue = default(TValue))
       {
           if (val == null || !val.Any()) return defValue;
           TValue returnValue;
           if (val.TryGetValue(key, out returnValue))
           {
               //if (returnValue == null) return defValue;
               return returnValue ;
           }
           return defValue;
       }
    }
}
